<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>对接</title>
    <link type="text/css" href="/quanliadmin/docroot/css/toolbar.css" rel="stylesheet" />
    <script language="JavaScript" src="/framework/jquery/jquery.min.js?v=20140719" type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/code/md5.js" type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/code/ccic2JwsPhone.js"
            type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/code/jWebSocket.js" type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/code/ccic2JwsClient.js"
            type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/code/stateMachine.js" type="text/javascript"></script>
    <script src="http://sh.ccic2.com/jws/sourceCode/softphone/sipActive.js"
            type="text/javascript"></script>
    <style type="text/css">
        *, html, body
        {
            padding: 0;
            margin: 0;
            overflow: hidden;
            font-size: 12px;
        }
    </style>
    <script type="text/javascript">
        setServerUrl("sh.ccic2.com");
    </script>
</head>
<script type="text/javascript">
$(document).ready(function () {//页面加载完毕
    if (buttType) {
        if (typeof window.external.readyLoad != 'undefined') {
            window.external.readyLoad("ready");
        }
    } else {
        if (typeof window.parent.readyLoad != 'undefined') {
            window.parent.readyLoad("ready");
        }
    }
})
function cbLogout(token) {//退出
    if (buttType) {
        token = JSON.parse(token);
    }
    if (token.code == "0") {
        typeButton.buttonDisabled();
        $("#statusImg").css({ "backgroundPosition": "0px 0px" });
        $('#status').text("离线");
    }
}
function cbWelcome(token) {//连接成功

}

function cbKickout(token) {
    typeButton.buttonDisabled();
    $("#statusImg").css({ "backgroundPosition": "0px 0px" });
    $('#status').text("离线");
    parent.window.document.getElementById("btnCcicLogin").value = '登陆';
    parent.$.messager.alert("提示", "已在其他地方重新登录！系统关闭！", "error");
}
var typeButton = {
    phoneCallout: function () {//外呼
        $("#phoneCallout").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#phoneCallout").unbind("mouseover mouseout click");
        $("#phoneCallout").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                var params = {};
                params.tel = $('#phoneCallText').val();
                params.callType = '3'; //3点击外呼
                executeAction('doPreviewOutCall', params);
            }
        });
    },
    phoneCallText: function () {
        $("#phoneCallText").attr("disabled", false);
    },
    phoneCallCancel: function () {//外呼取消
        $("#phoneCallCancel").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#phoneCallCancel").unbind("mouseover mouseout click");
        $("#phoneCallCancel").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doPreviewOutcallCancel');
            }
        });
    },
    //        refused: function () {//拒接
    //            $("#refused").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
    //            $("#refused").unbind("mouseover mouseout click");
    //            $("#refused").bind({
    //                mouseover: function () {
    //                    $(this).css({ "backgroundPosition": "0px -66px" });
    //                },
    //                mouseout: function () {
    //                    $(this).css({ "backgroundPosition": "0px -33px" });
    //                },
    //                click: function () {
    //                    executeAction('doRefuse');
    //                }
    //            });
    //        },
    unLink: function () {//挂断
        $("#unLink").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#unLink").unbind("mouseover mouseout click");
        $("#unLink").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doUnLink');
            }
        });
    },
    hold: function () {//保持
        $("#hold").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#hold").unbind("mouseover mouseout click");
        $("#hold").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doHold');
            }
        });
    },
    unHold: function () {//保持接回
        $("#unHold").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#unHold").unbind("mouseover mouseout click");
        $("#unHold").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doUnhold');
            }
        });
    },
    investigation: function () {//满意度调查
        $("#investigation").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#investigation").unbind("mouseover mouseout click");
        $("#investigation").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doInvestigation');
            }
        });
    },
    online: function () {//空闲
        $("#online").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#online").unbind("mouseover mouseout click");
        $("#online").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                executeAction('doUnpause');
            }
        });
    },
    pause: function () {//置忙
        $("#pause").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#pause").unbind("mouseover mouseout click");
        $("#pause").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                var param = {};
                param.description = "置忙";
                executeAction('doPause', param);

            }
        });
    },
    buttonDisabled: function () {
        $("#toolbarButton input").css({ "backgroundPosition": "0px 0px" });
        $("#toolbarButton input").attr("disabled", true);
        $("#toolbarButton input").unbind("mouseover mouseout click");
    },
    //        consult: function () {//咨询
    //            $("#consult").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
    //            $("#consult").unbind("mouseover mouseout click");
    //            $("#consult").bind({
    //                mouseover: function () {
    //                    $(this).css({ "backgroundPosition": "0px -66px" });
    //                },
    //                mouseout: function () {
    //                    $(this).css({ "backgroundPosition": "0px -33px" });
    //                },
    //                click: function () {

    //                }
    //            });
    //        },
    //        consultTransfer: function () {//咨询转接
    //            $("#consultTransfer").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
    //            $("#consultTransfer").unbind("mouseover mouseout click");
    //            $("#consultTransfer").bind({
    //                mouseover: function () {
    //                    $(this).css({ "backgroundPosition": "0px -66px" });
    //                },
    //                mouseout: function () {
    //                    $(this).css({ "backgroundPosition": "0px -33px" });
    //                },
    //                click: function () {

    //                }
    //            });
    //        },
    //        consultThreeway: function () {//咨询三方
    //            $("#consultThreeway").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
    //            $("#consultThreeway").unbind("mouseover mouseout click");
    //            $("#consultThreeway").bind({
    //                mouseover: function () {
    //                    $(this).css({ "backgroundPosition": "0px -66px" });
    //                },
    //                mouseout: function () {
    //                    $(this).css({ "backgroundPosition": "0px -33px" });
    //                },
    //                click: function () {


    //                }
    //            });
    //        },
    transfer: function () {//转移
        $("#transfer").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
        $("#transfer").unbind("mouseover mouseout click");
        $("#transfer").bind({
            mouseover: function () {
                $(this).css({ "backgroundPosition": "0px -66px" });
            },
            mouseout: function () {
                $(this).css({ "backgroundPosition": "0px -33px" });
            },
            click: function () {
                var str = prompt("请输入坐席号", "2002");
                if (str != '' && str.length == 4) {
                    var p = {};
                    p.transferObject = str;
                    p.objectType = "1";
                    executeAction("doTransfer", p);
                } else {
                    $.messager.alert("提示", "坐席号不合法！", "info");
                }
            }
        });
    },
    answer: function () {//接听 软电话功能
        if (userBasic.getBindType() == '3') {
            $("#answer").show().attr("disabled", false).css({ "backgroundPosition": "0px -33px" });
            $("#answer").unbind("mouseover mouseout click");
            $("#answer").bind({
                mouseover: function () {
                    $(this).css({ "backgroundPosition": "0px -66px" });
                },
                mouseout: function () {
                    $(this).css({ "backgroundPosition": "0px -33px" });
                },
                click: function () {
                    executeAction('doLink');
                }
            });
        }

    }
}
function cbThisStatus(token) {
    if (buttType) {
        token = JSON.parse(token);
    }
    switch (token.eventName) {
        case 'outRinging': //外呼座席响铃
            if (token.name == "ringing") {
                typeButton.buttonDisabled();
                typeButton.answer(token);
                //$("#phoneCallout").hide();
                typeButton.phoneCallCancel();
                //第三方代码
                top.CTI_ID = token.uniqueId; //获取录音编号
            }
            break;
        case 'comeRinging': //呼入座席响铃
            if (token.name == "ringing") {
                typeButton.buttonDisabled();
                typeButton.answer(token);
                //                    typeButton.refused();
            }
            break;
        case 'normalBusy': //呼入座席接听
            typeButton.buttonDisabled();
            typeButton.unLink();
            typeButton.hold();
            typeButton.investigation();

            //typeButton.consult();
            // typeButton.consultThreeway();
            //typeButton.consultTransfer();
            typeButton.transfer();
            break;
        case 'outBusy': //外呼客户接听 客户和座席通话
            typeButton.buttonDisabled();
            typeButton.unLink();
            typeButton.hold();
            typeButton.investigation();

            //typeButton.consult();
            //typeButton.consultThreeway();
            //typeButton.consultTransfer();
            typeButton.transfer();
            break;
        case 'online': //置闲
            typeButton.buttonDisabled();
            typeButton.phoneCallout();
            typeButton.phoneCallText();
            typeButton.pause();
            //$("#phoneCallCancel").hide();
            break;
        case 'pause': //置忙
            typeButton.buttonDisabled();
            typeButton.phoneCallout();
            typeButton.phoneCallText();
            typeButton.online();

            //$("#phoneCallCancel").hide();
            break;
        case 'waitLink': //外呼座席接听等待客户接听

            break;
        case 'neatenStart': //整理开始（座席挂断）
            typeButton.buttonDisabled();
            typeButton.online();
            typeButton.pause();
            break;
        case 'neatenEnd': //整理结束
            typeButton.buttonDisabled();
            typeButton.phoneCallout();
            typeButton.phoneCallText();
            var s = deviceStatus.deviceStatusLoginStatus(token.deviceStatus + token.loginStatus, token.pauseDescription, token.busyDescription);
            if (s == '空闲') {
                typeButton.pause();
            } else {
                typeButton.online();
            }
            break;
        case 'hold': //保持开始
            typeButton.buttonDisabled();
            typeButton.unLink();
            typeButton.unHold();
            typeButton.investigation();
            break;
        case 'unHold': //保持结束
            typeButton.buttonDisabled();
            typeButton.unLink();
            typeButton.hold();
            typeButton.investigation();

            //typeButton.consult();
            //typeButton.consultThreeway();
            // typeButton.consultTransfer();
            typeButton.transfer();
            break;
        case 'onlineUnlink': //挂断后置闲
            typeButton.buttonDisabled();
            typeButton.phoneCallout();
            typeButton.phoneCallText();
            typeButton.pause();
            break;
        case 'pauseUnlink': //挂断后置忙
            typeButton.buttonDisabled();
            typeButton.phoneCallout();
            typeButton.phoneCallText();
            typeButton.online();
            break;

    }
    var str = deviceStatus.deviceStatusLoginStatus(token.deviceStatus + token.loginStatus, token.pauseDescription, token.busyDescription);
    if (str != "") {
        $("#status").text(str);
    }
    if (str == '空闲') {
        $("#statusImg").css({ "backgroundPosition": "0px -25px" });
    } else if (str == '离线') {
        $("#statusImg").css({ "backgroundPosition": "0px 0px" });
    } else {
        $("#statusImg").css({ "backgroundPosition": "0px -50px" });
    }

    //============================================================
    //第三方代码写在下面
    if (token.eventName == "outRinging") {//外呼座席响铃
        //top.CTI_ID = token.uniqueId;//获取录音编号
    } else if (token.eventName == "comeRinging") {//呼入座席响铃
        if (token.customerNumber == "") {
            return;
        }
        parent.ebsig_come_ringing(token.customerNumber);
        return;
    } else if (token.eventName == "online") {//置闲

    } else if (token.eventName == "normalBusy") {//呼入座席接听

    } else if (token.eventName == "outBusy") {//外呼客户接听

    } else if (token.eventName == "pause") {//置忙

    } else if (token.eventName == "waitLink") {//座席接听 等待客户接听

    } else if (token.eventName == "neatenStart") {//整理开始（座席挂断）

    } else if (token.eventName == "neatenEnd") {//整理结束

    } else if (token.eventName == "hold") {//保持开始

    } else if (token.eventName == "unHold") {//保持结束

    }
    //============================================================
}


</script>
<body>
<table border="0" cellspacing="0" cellpadding="0" style="margin: 0; padding: 0; border-collapse: collapse;">
    <tr>
        <td align="center">
                <span style="background: url('/quanliadmin/docroot/images/ccic/tb1.png') no-repeat; width: 24px; height: 24px;
                    display: block;" id="statusImg"></span>
        </td>
        <td align="center" id="status" width="40" style="text-align: left; padding-left: 2px;">
            离线
        </td>
        <td id="toolbarButton" style="margin: 0; padding: 0; text-align: left;">
            <input type="button" id="pause" style="border: none; width: 56px; height: 33px; background: url('/quanliadmin/docroot/images/ccic/toobarBtn_zx.png') no-repeat;
                    float: left;" />
            <input type="button" id="online" style="border: none; width: 57px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_zm.png') no-repeat; float: left;" />
            <input type="button" id="answer" value="" style="border: none; width: 57px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_link.png') no-repeat; float: left;" />
            <input type="button" id="unLink" value="" style="border: none; width: 57px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_gd.png') no-repeat; float: left;" />

            <input type="button" id="hold" value="" style="border: none; width: 57px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_bc.png') no-repeat; float: left;" />
            <input type="button" id="unHold" value="" style="border: none; width: 80px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_bcjh.png') no-repeat; float: left;" />

            <input type="button" id="transfer" value="" style="border: none; width: 57px; height: 33px;
                    background: url('/quanliadmin/docroot/images/ccic/toobarBtn_zy.png') no-repeat; float: left;" />
            <input type="button" id="investigation" value="" style="border: none; width: 90px;
                    height: 33px; background: url('/quanliadmin/docroot/images/ccic/toobarBtn_myddc.png') no-repeat; float: left;" />
            <input type="text" id="phoneCallText" value="" maxlength="11" style="display: inline-block;
                    width: 90px; height: 28px; line-height: 28px; font-family: verdana; border: solid 1px #ddd;
                    vertical-align: top; margin-top: 2px; float: left;" />
            <input type="button" id="phoneCallout" value="" style="border: none; width: 80px;
                    height: 33px; background: url('/quanliadmin/docroot/images/ccic/toobarBtn_wh.png') no-repeat; float: left;" />
            <input type="button" id="phoneCallCancel" value="" style="border: none; width: 80px;
                    height: 33px; background: url('/quanliadmin/docroot/images/ccic/toobarBtn_whqx.png') no-repeat; float: left;" />
        </td>
    </tr>
</table>
</body>
</html>
